import { LayerManager } from "../../manager/LayerManager";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GameController } from "../../mvc/GameController";
import { GameUI } from "../mainUI/GameUI";
import { LevelAwardItem } from "./LevelAwardItem";
//class LevelAwardPanel
    
    export  class LevelAwardPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.layer = LayerManager.uiLayer;
            this._layer.addPopUp(this);
            this.addAwardItem();
            return;
        }

        public get layer(): ILayer
        {
            return this._layer;
        }

        public set layer(arg1: ILayer)
        {
            this._layer = arg1;
            return;
        }

        public setAwardInfo(arg1: Object): void
        {
            this._data = arg1;
            this._awardArr = arg1.reward;
            this._awardItem.flyLevelAwardToNavbar();
            if (this._awardArr.length > 0) 
            {
                this._awardItem.setData(arg1);
            }
            else if (this._awardItem) 
            {
                this._awardItem.onRemove();
                removeChild(this._awardItem);
                (GameController.gameui.view as GameUI).removeLevelAward();
            }
            return;
        }

        /* internal  */addAwardItem(): void
        {
            this._awardItem = new LevelAwardItem();
            this._awardItem.x = 0;
            this._awardItem.y = 0;
            addChild(this._awardItem);
            return;
        }

        public dispose(): void
        {
            if (this._awardItem) 
            {
                this._awardItem.onRemove();
                this._awardItem = null;
            }
            return;
        }

        /* internal */ /* var */_layer: ILayer;

        /* internal */ /* var */_data: Object;

        /* internal */ /* var */_awardArr: Array<any>;

        /* internal */ /* var */_awardItem: LevelAwardItem;
    }
